<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户编码demo</title>
		<style type="text/css">
		</style>
		<script src="../jquery-1.8.3.min.js"></script>
		<script>
				/* $(function(){ */
					$.ajax({
					
						url:"http://localhost:8091/getAll",
						data:"id=100&name=Tom",
						
						success:function(data){
							for(user of data){
								var tr=`<tr align="center">
											<td class="info">${user.id}</td>
											<td class="info">${user.name}</td>
											<td class="info">${user.age}</td>
											<td class="info">${user.sex}</td>
											<td>
												<button id="b1" >修改</button>
												<button id="b2" onclick="del(${user.id})">删除</button>
											</td>
										</tr>`
								
								$("#table1").append(tr)
								
								
							} 
						},
						async:true
					})
				/* }) */
					
				
			
			/* 这个函数不能放在循环里,也不能放在ajax里 */
			function del(d){
					$.ajax({
						url:"http://localhost:8091/delete",
						data:{id:d},
						/* success:function(data){
							console.log("删除成功");
						} */
					})
			}	 
			
		</script>
	</head>
	<body>
		<table id="table1" border="1px" align="center" width="80%">
			<tr>
				<td colspan="5" align="center" ><h1>用户的列表</h1></td>
			</tr>
			<tr>
				<td align="center" id="az">编号</td>
				<td align="center">姓名</td>
				<td align="center">年龄</td>
				<td align="center">性别</td>
				<td align="center">操作</td>
				<!-- <button  onclick="insert(5)">111</button> -->
				
			</tr>
			
			
		</table>
	</body>
</html>
